package com.example.home_model;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.example.common.filed.DataActionEntity;
import com.example.common.mlivedata.LiveDataBus;
import com.example.common.mvvm.viewmodel.BaseViewModel;
import com.example.home_model.entity.VideoEntity;
import com.example.network_skd.BaseEntity;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class VideoViewModel extends BaseViewModel<VideoRepository> {
    @Override
    protected void initData() {
        Map<String,Object> map = new HashMap<>();

        map.put("feedId", 0);
        map.put("feedType", "");
        map.put("pageCount", 10);
        map.put("userId", 0);

        repository.queryHotFeedsList(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }

    @Override
    protected void onResult(BaseEntity baseEntity) {
        if (baseEntity instanceof VideoEntity){
            VideoEntity videoEntity = (VideoEntity) baseEntity;
            DataActionEntity dataActionEntity = new DataActionEntity();
            dataActionEntity.action="DATA";
            Map<String,Object> map = new HashMap<>();

            map.put("VIDEODATA",videoEntity.data);
            dataActionEntity.data =map;
            vmData.post(dataActionEntity);
        }
    }
}
